<script>
function setFocus(){
	$('identity').focus()
}

function box_message(titleMessage,message){
	box_message = new LightFace({ 
			title: titleMessage, 
			width : 300,
			content: "<div class='message'>"+message+"</div>"
			,
			buttons: [{ title: 'Close', event: function() { this.close();}, color: 'green'}]
		});
		box_message.open();	
}

function resetForm(){
	$('identity').set('value','');
	$('name').set('value','');
	$('place_of_birth').set('value','');
	$('birthday').set('value','');
	$('education').set('value','');
	$('work').set('value','');
	$('email').set('value','');
	$('website').set('value','');
	$('phone').set('value','');
	$('address').set('value','');
	$('city').set('value','');
	$('achievment').set('value','');
	$('radio').set('checked','unchecked');
}

function save_anggota(form, evt){
	var msg = "";
	new Event(evt).stop();
	form = $(form);
		form.set('send', {
			url:'<?php echo site_url(array('just4me','anggota_save'))?>',
			method :'post',
		 	onSuccess: function(responseText, responseXML){	
			 	resetForm();	
				box_message("Confirmation","Data has been save");
			},
			onComplete: function(){
				
			},
			onFailure: function(xhr){
				var message = "Failed to save";
				failure(message);
			}
		});
		form.send();
	return false;
}

window.addEvent('load', function(){

		new DatePicker('.demo_noyear', { 
			pickerClass: 'datepicker_vista', 
			yearPicker:	true,
			format: 'Y-m-d' ,
			allowEmpty: true,
			startView:'decades',
		});
		
	//setFocus();
        new FormCheck('anggota_add', {
		display : {
			errorsLocation : 1,
			showErrors : 1,
			addClassErrorToField : 1
		}
	})
});

</script>
<form name="anggota_add" id="anggota_add" method="post" enctype="multipart/form-data" onSubmit="save_anggota(this, event)">
  <table width="0%" border="0" cellspacing="2" cellpadding="3">
    <tr>
      <td valign="top"><table width="0%" border="0" cellspacing="2" cellpadding="3">
        <tr>
          <th align="right">Iidentity</th>
          <td>
            <input name="identity" placeholder="ktp/sim" type="text" id="identity" size="30" maxlength="25" class="validate['required']"></td>
        </tr>
        <tr>
          <th align="right">Name</th>
          <td>
            <input name="name" type="text" id="name" size="35" maxlength="100" class="validate['required']"></td>
        </tr>
        <tr>
          <th align="right">Birthday</th>
          <td><input placeholder="Tempat Lahir" name="place_of_birth" type="text" id="place_of_birth" class="validate['required']" size="20" maxlength="100">
            <input placeholder="yyyy-mm-dd" name="birthday" type="text" id="birthday" class="date demo_noyear" size="15"></td>
        </tr>
        <tr>
          <th align="right" valign="top">Gender</th>
          <td><input name="gender" type="radio" id="radio" value="Laki - Laki" checked>
            Laki-Laki<br>
              <input type="radio" name="gender" id="gender" value="Perempuan">
              Perempuan</td>
        </tr>
        <tr>
          <th align="right">Education</th>
          <td><input name="education" type="text" id="education" maxlength="100" placeholder="Pendidikan Terakhir"></td>
        </tr>
        <tr>
          <th align="right">Work</th>
          <td><input name="work" type="text" id="work" maxlength="100" placeholder="Pekeerjaan"></td>
        </tr>
        <tr>
          <th align="right">Skill</th>
          <td><select name="skill" id="skill">
           	<option value=""> </option>
            <option value="Perangkat Lunak">Perangkat Lunak</option>
            <option value="Perangkat Keras">Perangkat Keras</option>
            <option value="Jaringan">Jaringan</option>
            <option value="Keamanan Sistem">Keamanan Sistem</option>
            <option value="Database">Database</option>
            <option value="Multimedia">Multimedia</option>
          </select></td>
        </tr>
        <tr>
          <th align="right" valign="top">Achievment</th>
          <td>
            <textarea name="achievment" id="achievment" cols="45" rows="6"></textarea></td>
        </tr>
      </table></td>
      <td valign="top"><table width="0%" border="0" cellspacing="2" cellpadding="3">
        <tr>
          <th align="right">Email</th>
          <td>
            <input name="email" type="text" id="email" size="30" maxlength="150" class="validate['required','email']"></td>
        </tr>
        <tr>
          <th align="right">Website</th>
          <td>
            <input name="website" type="text" id="website" size="30" maxlength="150""></td>
        </tr>
        <tr>
          <th align="right">Phone</th>
          <td><input name="phone" type="text" id="phone" size="25" maxlength="20" class="validate['required','phone']"></td>
        </tr>
        <tr>
          <th align="right" valign="top">Address</th>
          <td><input name="address" type="text" id="address" size="40" maxlength="200" class="validate['required']"></td>
        </tr>
        <tr>
          <th align="right">Region</th>
          <td>
            <select name="region" id="region">
              	<option value="Jawa Timur">Jawa Timur</option>
                <option value="Nanggro Aceh Darussalam">Nanggro Aceh Darussalam</option>
                <option value="Sumatra Utara">Sumatra Utara</option>
                <option value="Sumatra Barat">Sumatra Barat</option>
                <option value="Riau">Riau</option>
                <option value="Riau Kepulauan">Riau Kepulauan</option>
                <option value="Jambi">Jambi</option>
                <option value="Sumatra Selatan">Sumatra Selatan</option>
                <option value="Bangka Belitung">Bangka Belitung</option>
                <option value="Bengkulu">Bengkulu</option>
                <option value="Lampung">Lampung</option>
                <option value="DKI Jakarta">DKI Jakarta</option>
                <option value="Jawa Barat">Jawa Barat</option>
                <option value="Banten">Banten</option>
                <option value="Jawa Tengah">Jawa Tengah</option>
                <option value="DI Yogyakarta">DI Yogyakarta</option>
                <option value="Jawa Timur">Jawa Timur</option>
                <option value="Bali">Bali</option>
                <option value="NTB">NTB</option>
                <option value="NTT">NTT</option>
                <option value="Kalimantan Barat">Kalimantan Barat</option>
                <option value="Kalimantan Tengah">Kalimantan Tengah</option>
                <option value="Kalimantan Timur">Kalimantan Timur</option>
                <option value="Kalimantan Selatan">Kalimantan Selatan</option>
                <option value="Sulawesi Utara">Sulawesi Utara</option>
                <option value="Gorontalo">Gorontalo</option>
                <option value="Sulawesi Tengah">Sulawesi Tengah</option>
                <option value="Sulawesi Barat">Sulawesi Barat</option>
                <option value="Sulawesi Selatan">Sulawesi Selatan</option>
                <option value="Sulawesi Tenggara">Sulawesi Tenggara</option>
                <option value="Maluku">Maluku</option>
                <option value="Maluku Utara">Maluku Utara</option>
                <option value="Papua Barat">Papua Barat</option>
                <option value="Papua">Papua</option>
            </select></td>
        </tr>
        <tr>
          <th align="right">City</th>
          <td><input name="city" type="text" id="city" size="25" maxlength="100" class="validate['required']"></td>
        </tr>
        <tr>
          <th align="right" valign="top">Blood</th>
          <td valign="top"><input type="radio" name="blood" id="blood" value="A">
            A
            <br>
            <input type="radio" name="blood" id="blood" value="B">
            B
            <br>
            <input type="radio" name="blood" id="blood" value="AB">
            AB<br>
  			<input name="blood" type="radio" id="blood" value="O" checked>
            O</td>
        </tr>
      </table></td>
    </tr>
    <tr>
      <td valign="top">&nbsp;</td>
      <td align="right" valign="top"><input type="submit" name="button" id="button" value="Save" class="uiButtonRounded">
      <input type="reset" name="button2" id="button2" value="Reset" class="uiButtonRounded"></td>
    </tr>
  </table>
</form>